import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;

/**
 * Created by Administrator on 2017/10/19.
 */
public class hbb {

    public static void main(String [] args) throws Exception{
        JSONArray all = read(null);
        JSONArray lv3 = new JSONArray();
        for(int i = 0 ; i < all.size(); i ++){
            JSONObject data = all.getJSONObject(i);
            JSONObject vc = new JSONObject();
            vc.put("name",data.getString("name"));
            JSONArray vclist = new JSONArray();
            JSONArray city = data.getJSONArray("list");
            for(int j = 0; j < city.size(); j ++){
                JSONObject cdata = city.getJSONObject(j);
                JSONObject vcc =  new JSONObject();
                vcc.put("name",cdata.getString("name"));
                JSONArray vcclist = new JSONArray();
                JSONArray country = cdata.getJSONArray("list");
                for(int k = 0 ; k < country.size(); k++){
                    JSONObject kdata = country.getJSONObject(k);
                    JSONObject vk = new JSONObject();
                    vk.put("name",kdata.getString("name"));
                    vcclist.add(vk);
                }
                vcc.put("list",vcclist);
                vclist.add(vcc);
            }
            vc.put("list",vclist);
            lv3.add(vc);
        }
    }



    private static JSONArray read(File __file) throws Exception{
        File file = new File("e:/citys/all.json");
        String temp;
        BufferedReader read = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
        StringBuilder result = new StringBuilder();
        while((temp = read.readLine()) != null){
            result.append(temp);
        }
        return (JSONArray)JSON.parse(result.toString());
    }
}
